//
//  MSShowerCell.m
//  MS
//
//  Created by Yuan on 13-2-15.
//  Copyright (c) 2013年 He Yuan. All rights reserved.
//

#import "MSShowerCell.h"
#import <QuartzCore/QuartzCore.h>

@implementation MSShowerCell

@synthesize topNavImageViewbg;
@synthesize avatarButton;
@synthesize avatarFlagButton;
@synthesize aliasLbl; //昵称
@synthesize addressLbl;
@synthesize timeLbl; //时间
@synthesize commentCountLbl; //评论
@synthesize commentButton;
@synthesize likeCountLbl; //喜欢
@synthesize likeButton;
@synthesize imageAndTxtView;


-(void)dealloc
{
    topNavImageViewbg = nil;
    aliasLbl = nil;
    addressLbl = nil;
    timeLbl = nil;
    commentCountLbl = nil;
    likeCountLbl = nil;
    imageAndTxtView = nil;
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        // Initialization code
        topNavImageViewbg = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320,44)];
        [topNavImageViewbg setImage:[UIImage imageNamed:@"shower_cell_navbg"]];
        [self.contentView addSubview:topNavImageViewbg];
        
        CGFloat margin_top = 7.0f;
        
        avatarButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [avatarButton setFrame:CGRectMake(6,4, 36,36)];
        avatarButton.layer.cornerRadius = 2.0;
        [avatarButton setUserInteractionEnabled:YES];
        avatarButton.layer.masksToBounds = YES;
        [self.contentView addSubview:avatarButton];
     
        avatarFlagButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [avatarFlagButton setFrame:CGRectMake(6,4,16,16)];
        avatarFlagButton.center = CGPointMake(avatarButton.center.x+avatarButton.frame.size.width/2-5.0, avatarButton.center.y+avatarButton.frame.size.height/2-5.0);
        [avatarFlagButton setUserInteractionEnabled:NO];
        [self.contentView addSubview:avatarFlagButton];
        
        aliasLbl = [[UILabel alloc]initWithFrame:CGRectMake(48.0f, margin_top-6.0, 105.0f, 25.0f)];
        [aliasLbl setTextColor:[UIColor colorWithRed:0.720 green:0.225 blue:0.165 alpha:1.000]];
        [aliasLbl setFont:FONT_MIDDLE_BOLD];
        [aliasLbl setContentMode:UIViewContentModeScaleAspectFit];
        [aliasLbl setBackgroundColor:[UIColor clearColor]];
        [aliasLbl setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:aliasLbl];
      
        addressLbl = [[UILabel alloc]initWithFrame:CGRectMake(48.0f,24,40.0f, 18.0f)];
        [addressLbl setTextColor:[UIColor grayColor]];
        [addressLbl setFont:FONT_SMALL];
        [addressLbl setContentMode:UIViewContentModeScaleAspectFit];
        [addressLbl setBackgroundColor:[UIColor clearColor]];
        [addressLbl setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:addressLbl];
        
        timeLbl = [[UILabel alloc]initWithFrame:CGRectMake(90.0f, 24, 90.0f, 18.0f)];
        [timeLbl setTextColor:[UIColor grayColor]];
        [timeLbl setFont:FONT_SMALL];
        [timeLbl setContentMode:UIViewContentModeScaleAspectFit];
        [timeLbl setBackgroundColor:[UIColor clearColor]];
        [timeLbl setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:timeLbl];
        
        commentCountLbl = [[UILabel alloc]initWithFrame:CGRectMake(225.0f,24, 40.0f, 18.0f)];
        [commentCountLbl setTextColor:[UIColor whiteColor]];
        [commentCountLbl setFont:FONT_SMALL];
        [commentCountLbl setShadowColor:[UIColor colorWithWhite:0.0 alpha:0.3]];
        [commentCountLbl setShadowOffset:CGSizeMake(1.0, 1.0)];
        [commentCountLbl setContentMode:UIViewContentModeScaleAspectFit];
        [commentCountLbl setTextAlignment:UITextAlignmentLeft];
        [commentCountLbl setBackgroundColor:[UIColor clearColor]];
        [commentCountLbl setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:commentCountLbl];
        
        commentButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [commentButton setFrame:CGRectMake(200,8.0,31, 27)];
        [commentButton setImage:[UIImage imageNamed:@"shower_cell_comment"] forState:UIControlStateNormal];
        [commentButton setUserInteractionEnabled:YES];
        [self.contentView addSubview:commentButton];
        
        likeCountLbl = [[UILabel alloc]initWithFrame:CGRectMake(282, 24, 36.0f, 18.0f)];
        [likeCountLbl setTextColor:[UIColor whiteColor]];
        [likeCountLbl setFont:FONT_SMALL];
        [likeCountLbl setShadowColor:[UIColor colorWithWhite:0.0 alpha:0.3]];
        [likeCountLbl setShadowOffset:CGSizeMake(1.0, 1.0)];
        [likeCountLbl setContentMode:UIViewContentModeScaleAspectFit];
        [likeCountLbl setTextAlignment:UITextAlignmentLeft];
        [likeCountLbl setBackgroundColor:[UIColor clearColor]];
        [likeCountLbl setAdjustsFontSizeToFitWidth:YES];
        [self.contentView addSubview:likeCountLbl];
        
        likeButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [likeButton setFrame:CGRectMake(260,8.0,31, 27)];
        [likeButton setImage:[UIImage imageNamed:@"shower_cell_like"] forState:UIControlStateNormal];
        [likeButton setUserInteractionEnabled:YES];
        [self.contentView addSubview:likeButton];
        
        imageAndTxtView = [[MSImageAndTextCellContentView alloc]initWithFrame:CGRectMake(40,55,220,290)];
        [self.contentView addSubview:imageAndTxtView];
        
    }
    return self;
}


-(void)layoutSubviews
{
    [super layoutSubviews];
    
    if ([imageAndTxtView.txtLbl.text length]>0)
    {
        [imageAndTxtView setTxtLblHeight:CELL_TXTLBL_HEIGHT(imageAndTxtView.txtLbl.text)];
    }
    else
    {
        [imageAndTxtView setTxtLblHeight:0];
    }
}


- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
